<cfparam name="Fund_ID" type="integer" />
<cfparam name="returnView" type="string" default="funds" />
<cfparam name="passback" type="string" default="" />

<cfscript>
	fundGateway = new assets.calgrants.com.gateway.FundGateway();
	fund = fundGateway.get(Fund_ID = Fund_ID, Organization_ID = IIf(Fund_ID gt 0 AND request.authUser.organizationID gt 0, request.authUser.organizationID, ""));
</cfscript>

<cfif fund.getFund_ID() gt 0>

	<cfscript>
		base = new assets.calgrants.com.Base();
		passbackQueryString = base.passbackToQueryString(passback);
		organizationGateway = new assets.calgrants.com.gateway.OrganizationGateway();
		organization = organizationGateway.get(Organization_ID = fund.getOrganization_ID());
		userGateway = new assets.calgrants.com.gateway.UserGateway();
		requestedBy = userGateway.get(User_ID = fund.getRequested_By_ID());
		approvedBy = userGateway.get(User_ID = fund.getApproved_By_ID());
		fundWorkshopGateway = new assets.calgrants.com.gateway.FundWorkshopGateway();
		fundWorkshops = fundWorkshopGateway.query(Fund_ID = fund.getFund_ID());
		oapGateway = new assets.calgrants.com.gateway.OAPGateway();
		qOap = oapGateway.query(Organization_ID = fund.getOrganization_ID(), Program_Year = request.currentProgramYear);
		oap = oapGateway.get(OAP_ID = qOAP.OAP_ID);
		oapValueGateway = new assets.calgrants.com.gateway.OAPValueGateway();
		oapValues = oapValueGateway.query(oapValueIDs = oap.getOAP_Value_IDs());
		if (fund.getProgram_Year() eq "2014-2015") {
			fundSurveyGateway = new assets.calgrants.com.gateway.FundSurvey2015Gateway();
		} else if (fund.getProgram_Year() eq "2013-2014") {
			fundSurveyGateway = new assets.calgrants.com.gateway.FundSurvey2014Gateway();
		} else if (fund.getProgram_Year() eq "2012-2013") {
			fundSurveyGateway = new assets.calgrants.com.gateway.FundSurvey2013Gateway();
		} else if (fund.getProgram_Year() eq "2011-2012") {
			fundSurveyGateway = new assets.calgrants.com.gateway.FundSurvey2012Gateway();
		} else if (fund.getProgram_Year() eq "2010-2011") {
			fundSurveyGateway = new assets.calgrants.com.gateway.FundSurvey2011Gateway();
		} else if (fund.getProgram_Year() eq "2009-2010") {
			fundSurveyGateway = new assets.calgrants.com.gateway.FundSurvey2010Gateway();
		}
		qFundSurvey = fundSurveyGateway.query(Fund_ID = fund.getFund_ID());
		fundSurvey = fundSurveyGateway.get(Fund_Survey_ID = IIf(fund.getFund_ID() gt 0, qFundSurvey.Fund_Survey_ID, 0));
	</cfscript>
	
	<script type="text/javascript">
		$(function() {
			$("#fundModal").modal();
			resizeModal("fundModal");
			// mark
		})
	</script>
	
	<style type="text/css">
		.slim-col {
			width: 70px;
		}
		.grid-table {
			width: 880px;
		}
		.q {
			padding-bottom: 10px;
		}
		.text-well {
			width: 820px;
		}
		.ta {
			width: 780px;
			height: 100px;
		}
	</style>

	<div id="fundModal" class="modal modal-fullscreen" data-backdrop="static">
		<div class="modal-header">
			<h3>Site Support Funds Request</h3>
		</div>
		<div class="modal-body">
					
			<div class="container-fluid">
				<!--- Payee Info --->
				<div class="row-fluid">
					<div class="span12">
						<h3>Payee Information</h3>
					</div>
				</div>
				<cfoutput>
					<div class="row-fluid">					
						<div class="span3">
							<div class="text-control clearfix">
								<label>Status</label>
								<cfif fund.getFund_ID() eq 0>
									New
								<cfelseif fund.getApproved() eq 1>
									Approved
								<cfelse>
									Pending Approval
								</cfif>
							</div>
							<div class="text-control clearfix">
								<label>Payee</label>
								#fund.getPayee_First_Name()# #fund.getPayee_Last_Name()#<br />
								#fund.getPayee_Phone()#<br />
								#fund.getPayee_Email()#
							</div>
						</div>
						<div class="span3">
							<div class="text-control clearfix">
								<label>Payment Recipient</label>
								#fund.getPayee_Organization()#<br />
								<cfif Len(Trim(fund.getPayee_Department())) gt 0>
									#fund.getPayee_Department()#<br />
								</cfif>
								#fund.getPayee_Address()#<br />
								#fund.getPayee_City()#, CA #fund.getPayee_Zip_Code()#
								<cfif IsUserInRole("Super User") or IsUserInRole("Regional Admin")>
									<br />Tax ID: #fund.getPayee_Tax_ID()#
								</cfif>
							</div>
						</div>
						<div class="span3">
							<cfif fund.getFund_ID() gt 0>
								<div class="text-control">
									<label>Requested By</label>
									#requestedBy.getFirst_Name()# #requestedBy.getLast_Name()#<br />
									#organization.getOrganization()#<br />
									#organization.getAddress()#<br />
									#organization.getCity()#, CA #organization.getZip_Code()#<br />
									<a href="mailto:#requestedBy.getEmail()#">#requestedBy.getEmail()#</a><br />
									#requestedBy.getPhone()#<cfif Len(Trim(requestedBy.getExtension())) gt 0> x #requestedBy.getExtension()#</cfif>
								</div>
								<div class="text-control">
									<label>Signed By</label>
									#fund.getSignature()#
								</div>
							</cfif>
						</div>
						<div class="span3">
							<cfif fund.getApproved_By_ID() gt 0>
								<div class="text-control">
									<label>Approved By</label>
									#approvedBy.getFirst_Name()# #approvedBy.getLast_Name()#
								</div>
								<div class="text-control">
									<label>Approval Date</label>
									#DateFormat(fund.getApproved_Date(), "m/d/yyyy")#
								</div>
							</cfif>
						</div>
					</div>
				</cfoutput>
				<!--- Workshops --->
				<div class="row-fluid">
					<div class="span12">
						<h3>Workshops</h3>
						<!--- <p>Below are the workshops your organization conducted. Please provide total attendance counts based on sign in sheets or estimates of attendance. Student attendance counts are not the same as verified exit survey counts. Also indicate the basic services that were offered at your workshop.</p> --->
						<cfif fundWorkshops.RecordCount gt 0>
							<table class="table table-hover table-bordered">
								<thead>
									<tr>
										<th>Workshop</th>
										<th>Exit Surveys (Web/Paper)</th>
										<th>Funds Eligible</th>
										<th>Student Attendance</th>
										<th>Parent/Guardian Attendance</th>
										<th>Volunteer/Staff Attendance</th>
										<th>Computer Count</th>
										<th>Basic Services</th>
										<th>Payment Amount</th>
									</tr>
								</thead>
								<tbody>
									<!--- <tr>
										<td colspan="9">
											<cfoutput>
												#fundWorkshops.columnList#
											</cfoutput>
										</td>
									</tr> --->
									<cfoutput query="fundWorkshops">
										<cfset pbStudentCount = IIf(Workshop_Student_Count_PB eq 0 and PB_Survey_Count gt 0, PB_Survey_Count, Workshop_Student_Count_PB) />
										<cfset studentCount = Workshop_Student_Count_Web + pbStudentCount />
										<cfif studentCount gte 30 and Workshop_Student_Count_Web gt 0>
											<cfset isEligible = true />
										<cfelse>
											<cfset isEligible = false />
										</cfif>
										<tr>
											<td>
												#Site#<br />
												#DateFormat(Workshop_Date, "m/d/yyyy")# #TimeFormat(Start_Time, "h:mmtt")#-#TimeFormat(End_Time, "h:mmtt")#
											</td>
											<td>#studentCount# (#Workshop_Student_Count_Web#/#pbStudentCount#)</td>
											<td>
												#YesNoFormat(isEligible)#
												<cfif NOT isEligible>
													<div style="margin-top: 8px;">
														Appeal
														<!--- <a href="##" id="fwaLink_#Workshop_ID#" onClick="openAppealModal(#Workshop_ID#); return false;" class="btn btn-success">Appeal</a> --->
													</div>
												</cfif>
											</td>
											<td>#Student_Count#</td>
											<td>#Parent_Count#</td>
											<td>#Volunteer_Count#</td>
											<td>#Computer_Count#</td>
											<td>
												<ul>
													<cfif Online><li>Computer lab access to complete FAFSA</li></cfif>
													<cfif FAFSA_On_The_Web><li>FAFSA on the Web worksheet presentation</li></cfif>
													<cfif Financial_Aid_Presentation><li>Cal Grant &amp; other financial aid overview</li></cfif>
													<cfif AB540><li>AB540/CA Dream Act assistance</li></cfif>
												</ul>
											</td>
											<td>#DollarFormat(Fund_Amount)#</td>
										</tr>
									</cfoutput>
								</tbody>
							</table>
						<cfelse>
							<p>There are no workshops associated with this Site Support Fund Request.</p>
						</cfif>
					</div>
				</div>
				<!--- OAP --->
				<div class="row-fluid">
					<div class="span12">
						<h3>Outreach Actvities</h3>
							<!--- <p>Below are the outreach activities you listed in your Outreach Action Plan. Please confirm which outreach activities were conducted by checking off the box to the left of the activity, and list any new activities not previously listed in your Outreach Action Plan.</p> --->
						<cfoutput query="oapValues" group="Category">
							<h4>#Category#</h4>
							<div class="well text-well">
								<cfoutput group="Subcategory">
									<cfif Len(Trim(Subcategory)) gt 0><p><u>#Subcategory#</u></p></cfif>
									<ul style="list-style-type: disc">
										<cfoutput>
											<cfif ListFind(fund.getOAP_Value_IDs(), OAP_Value_ID) gt 0>
												<li style="margin-top: 5px;" class="text-success">#Description#</li>
											<cfelse>
												<li style="margin-top: 5px;" class="text-error">#Description#</li>
											</cfif>
										</cfoutput>
									</ul>
								</cfoutput>
							</div>
						</cfoutput>
						<h4>Other Outreach Activities</h4>
						<p>If you performed other outreach activities not listed above, please describe:</p>
						<cfoutput>
							<div class="well text-well">
								<cfif Len(Trim(fund.getOAP_Other())) gt 0>
									#fund.getOAP_Other()#
								<cfelse>
									Did not answer
								</cfif>
							</div>
						</cfoutput>
					</div>
				</div>
				<!--- Survey --->
				<div class="row-fluid">
					<div class="span12">
						<h3>Organizer Survey</h3>
						<cfinclude template="/assets/calgrants/ui/details/fundSurvey2015.cfm">				
					</div>
				</div>
			</div>
			
		</div>
		<cfoutput>
		<div class="modal-footer">
			<a href="?view=#returnView#&#passbackQueryString#" class="btn btn-success">Close</a>
		</div>
		</cfoutput>
	</div>
<cfelse>

	<div class="alert alert-info notFound">Site Support Funds Request not found</div>
	
</cfif>